# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Jonathan Liu <net147@gmail.com>

_realname=wine
pkgbase=mingw-w64-wined3d
pkgname="${MINGW_PACKAGE_PREFIX}-wined3d"
pkgver=3.8
pkgrel=1
pkgdesc="Direct3D to OpenGL translator (mingw-w64)"
arch=('any')
depends=("")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
url="https://www.winehq.org"
license=('LGPL')
options=('staticlibs' 'strip')
source=(https://prdownloads.sourceforge.net/${_realname}/${_realname}-${pkgver}.tar.xz{.sign,})
sha256sums=('SKIP'
            '02b00c6c948b3bab717e1b1e2075a5406b14d138bd2e01fdb1268a93d1c20d51')

build() {
  case ${MINGW_CHOST} in
    i686*)
      _extra=
    ;;
    x86_64*)
      _extra="--enable-win64"
    ;;
  esac
  cd ${srcdir}/$_realname-$pkgver
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --disable-tests \
    --without-alsa \
    --without-capi \
    --without-coreaudio \
    --without-cups \
    --without-curses \
    --without-dbus \
    --without-fontconfig \
    --without-freetype \
    --without-gettext \
    --without-gphoto \
    --with-glu \
    --without-gnutls \
    --without-gsm \
    --without-gstreamer \
    --without-hal \
    --without-jpeg \
    --without-ldap \
    --without-mpg123 \
    --without-netapi \
    --without-openal \
    --without-opencl \
    --with-opengl \
    --without-osmesa \
    --without-oss \
    --without-png \
    --with-pthread \
    --without-sane \
    --without-tiff \
    --without-v4l \
    --without-xcomposite \
    --without-xcursor \
    --without-xinerama \
    --without-xinput \
    --without-xinput2 \
    --without-xml \
    --without-xrandr \
    --without-xrender \
    --without-xshape \
    --without-xshm \
    --without-xslt \
    --without-xxf86vm \
    --without-zlib \
    --without-x \
    $_extra \
    CFLAGS="-O2 -DUSE_WIN32_OPENGL -DWINE_NOWINSOCK"
  make LN_S='ln -s' dlls/d3d8 dlls/d3d9 dlls/d3d10 dlls/d3d10core dlls/dxgi dlls/wined3d
}

package() {
  cd ${srcdir}/$_realname-$pkgver
  mkdir -p ${pkgdir}${MINGW_PREFIX}/bin
  local _dll_files=( $(find ${srcdir}/$_realname-$pkgver -type f -name "*.dll") )
  cp -f ${_dll_files[@]} ${pkgdir}${MINGW_PREFIX}/bin/
}
